class Person():
    def __init__(self):
        self.__age = 18

    @property # 获取值  被@property装饰的方法名
    def age(self):
        return self.__age

    @age.setter  # 修改值  @方法名.setter
    def age(self,value):
        if str(value).isdigit():
            self.__age = value
        else:
            print("格式不对")
    @age.deleter  # 删除值 @方法名.deleter
    def age(self):
        del self.__age

p = Person()
p.age = 30
print(p.age)
# del p.age
# print(p.age)